// 深拷贝
export function deepCopy(target) {
  if (typeof target == 'object') {
      const result = Array.isArray(target)? [] : {}
      for (const key in target) {
          if (typeof target[key] == 'object') {
              result[key] = deepCopy(target[key])
          } else {
              result[key] = target[key]
          }
      }

      return result
  }
  
  return target
}

export function swap(arr, i, j) {
  const temp = arr[i]
  arr[i] = arr[j]
  arr[j] = temp
}

export function $(selector) {
  return document.querySelector(selector)
}